/*
 * Copyright (C) 2013 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

using UnityEngine;
using System.Collections;

// GUI Utils (Gu)
public class Gu {
    public static void Label(int x, int y, int fontSize, string text) {
        GUI.skin.label.fontSize = fontSize;
        GUI.Label(new Rect(x, y, Screen.width, Screen.height), text);
    }

    public static bool Button(int x, int y, int w, int h, Texture2D tex) {
        return GUI.Button(new Rect(x,y,w,h), tex);
    }

    public static bool Button(int x, int y, int w, int h, int fontSize, string text, GUIStyle style) {
        GUI.skin.button.fontSize = fontSize;
        style.fontSize = fontSize;
        return GUI.Button(new Rect(x,y,w,h), text, style);
    }

    public static bool Button(int x, int y, int w, int h, int fontSize, string text) {
        GUI.skin.button.fontSize = fontSize;
        return GUI.Button(new Rect(x,y,w,h), text);
    }


    public static int Dim(float units) {
        return (int)(units * Screen.height / 1000);
    }

    public static int Left(float units) {
        return Dim (units);
    }

    public static int Right(float units) {
        return Screen.width - Dim(units);
    }

    public static int Center(float units) {
        return Screen.width / 2 + Dim(units);
    }

    public static int Middle(float units) {
        return Screen.height / 2 + Dim(units);
    }

    public static int Top(float units) { return Dim(units); }

    public static int Bottom(float units) {
        return Screen.height - Dim(units);
    }

    public static Vector2 Measure(int fontSize, string s) {
        GUI.skin.label.fontSize = fontSize;
        return GUI.skin.customStyles[0].CalcSize(new GUIContent(s));
    }
}
